<%@page contentType="text/html" language="java" import="com.compuvest.web.*,java.util.*,java.lang.Integer,java.text.SimpleDateFormat" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<%
    if(request.getParameter("sid") == null) {
	response.sendRedirect("custsession.jsp");
	return;
    }

    final Map<String,Clickstream> clickstreams = (Map<String,Clickstream>)application.getAttribute("context.clientList");

    Clickstream stream = (Clickstream)clickstreams.get(request.getParameter("sid"));
    if(stream == null) {
	response.sendRedirect("custsession.jsp");
	return;
    }
//    SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
%>
<html>
<head><title>Admin</title>
<link rel="stylesheet" href="../incl/cv.css" type="text/css">
</head>
<body style="margin:0 0;padding:0 0;background-color:#b0c4de;">

<div><a href='custsession.jsp'>All sessions</a></div>
<h1>Session for <%= stream.getHostname() %></h1><br/>

<b>Referrer</b>: <a href='<%= stream.getInitialReferrer() %>'><%= stream.getInitialReferrer() %></a><br/>
<b>Hostname</b>: <%= stream.getHostname() %><br/>
<b>SessionID</b>: <%= request.getParameter("sid") %><br/>
<b>Session Start</b>: <%= stream.getStartRequest() %><br/>
<b>Last Request</b>: <%= stream.getLastRequest() %><br/>
<% long streamLenght = stream.getLastRequest().getTime() - stream.getStartRequest().getTime(); %>
<b>Session Length</b>: 
    <%= (streamLenght > 3600000? "" + (streamLenght / 3600000): "00:") +
        (streamLenght > 60000? "" + ((streamLenght / 60000) % 60): "00:") +
        (streamLenght > 1000? "" + ((streamLenght / 1000) % 60): "") %><br/>

<b># of Request</b>: <%= stream.getStream().size() %><br/>
<b>Clicks</b>:<br/>
<table width='100%' border=0 cellspacing=1 cellpadding=1 bgcolor=white>
 <tr><th width='3%'>#</th><th width='97%'>link</th></tr>
<%
    Iterator it = stream.getStream().iterator();
    int count = 0;
    while(it.hasNext()) {
	count++;
	String click = (String)it.next();
%>
 <tr bgcolor='<%= (count % 2 == 0)? "#d3d3d3": "#dcdcdc" %>' align=center>
  <td><%= count %></td>
  <td align=left><a href='http://<%= click %>'><%= click %></a></td>
 </tr>
<%
    }
%>
</table>

</body>
</html>
